using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;

namespace Sedna.Core.Controller
{
    public class CallContext: ICallContext
    {
        private const string RESULT_KEY = "result";
        private IDictionary inner = new ListDictionary();

        public object Collapse()
        {
            object result = Result;
            Clear();
            return result;
        }

        public object Result
        {
            get { return inner[RESULT_KEY]; }
            set { inner[RESULT_KEY] = value; }
        }

        #region inner IDictionary delegate

        public bool Contains(object key)
        {
            return inner.Contains(key);
        }

        public void Add(object key, object value)
        {
            inner.Add(key, value);
        }

        public void Clear()
        {
            inner.Clear();
        }

        public IDictionaryEnumerator GetEnumerator()
        {
            return inner.GetEnumerator();
        }

        IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return ((System.Collections.IEnumerable)inner).GetEnumerator();
        }

        public void Remove(object key)
        {
            inner.Remove(key);
        }

        public System.Collections.ICollection Keys
        {
            get { return inner.Keys; }
        }

        public System.Collections.ICollection Values
        {
            get { return inner.Values; }
        }

        public bool IsReadOnly
        {
            get { return inner.IsReadOnly; }
        }

        public bool IsFixedSize
        {
            get { return inner.IsFixedSize; }
        }

        public object this[object key]
        {
            get { return inner[key]; }
            set { inner[key] = value; }
        }

        public void CopyTo(Array array, int index)
        {
            inner.CopyTo(array, index);
        }

        public int Count
        {
            get { return inner.Count; }
        }

        public object SyncRoot
        {
            get { return inner.SyncRoot; }
        }

        public bool IsSynchronized
        {
            get { return inner.IsSynchronized; }
        }

        #endregion
    }
}
